package com.addedstuff;

import cpw.mods.fml.common.network.Player;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;

public class Lightning_Blade extends ItemSword {

		public Lightning_Blade(int par1, EnumToolMaterial par2EnumToolMaterial) {
		super(par1, par2EnumToolMaterial);
		this.setCreativeTab(CreativeTabs.tabCombat);
	}
//uses ray casting to strike lightning where the middle of the cursor is
		public boolean hasEffect(ItemStack par1ItemStack) {
                return true;
        }

        public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World,
                        EntityPlayer par3EntityPlayer) {
                if (!par2World.isRemote) {
                        MovingObjectPosition Coord = par3EntityPlayer.rayTrace(300, 1);
                        if (Coord != null) {
                                EntityLightningBolt Lightning = new EntityLightningBolt(
                                                par2World, Coord.blockX, Coord.blockY, Coord.blockZ);

                                for (int i = 3; i > -2; i--) {
                                        par2World.spawnEntityInWorld(new EntityLightningBolt(
                                                        par2World, Coord.blockX + i * 2, Coord.blockY,
                                                        Coord.blockZ));
                                        par2World.addWeatherEffect(Lightning);
                                }
                        }
                }

                return par1ItemStack;
        }

        public void registerIcons(IconRegister iconReg) {
               itemIcon = iconReg.registerIcon("Brianmodbase:Thunder");
        }
        public int getDamageVsEntity (Entity par1Entity)
   	 {
   		 return 1000;
   	 }
}